home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / math / gle-3.000 / gle-3 / gle / source.txt < prev    next >
C/C++ Source or Header  |  1995-02-07  |  9KB  |  255 lines

  1. This file contains a very brief description of the source,  CGLE was
  2. my first project in C so my 'style' changed rather drastically
  3. from module to module.
  4.  
  5. The files that are most likely to need changing for porting purposes 
  6. are:
  7.     unixscr.c
  8.         This deals with output to the screen, it doesn't 
  9.         use multiple windows, just positioning and scrolling.
  10.     unixinkey.c
  11.         This has to interpret key strokes into the keyboard
  12.         commands defined in edt.h
  13.     d_*.c
  14.         This is the device driver, (assuming one of the 
  15.         standard ones won't do)  I'd suggest you start with
  16.         the nearest and then modify it.
  17.  
  18.  
  19. First a brief overview of the main modules (this list was compiled
  20. before gle was ported to UNIX so some files names are different
  21. for the unix version, e.g. unixscr.c instead of cursesscr.c:
  22.  
  23. GLE.C        The MAIN() program which calls edt or drawit.
  24.         depending on weather or not it is an interactive
  25.         or output driver.
  26.  
  27. EDT.C        EDT like editor which the user is normally in.
  28.         When you press F10 it calls DRAWIT
  29. MENU.C        The routines for dealing with the GRAPH form.
  30.  
  31. DRAWIT.C    Main routine for drawing the current GLE file, this calls
  32.         TOKEN.C to tokenize each line, then PASS.C to compile the 
  33.         gle commands into PCODE then finally it runs thru the 
  34.         PCODE calling RUN.C for each line of pcode.
  35. POLISH.C    Passes expression, produces reverse polish pcode exp.
  36. EVAL.C        Evaluates pcode expression.
  37. GLOBAL.H    Structures and data for PASSing gle source
  38. PASS.C        For passing each line of gle file, produces pcode.
  39. RUN.C        Executes one line of pcode. (draws it)
  40.  
  41.  
  42. -----------------------------------------------------------------------------
  43. The basic format of the pcode is a list of LONG integers, the first 
  44. one is the command (amove, if, text, box, etc) then come
  45. any requred parameters, followed by optional parameters in 
  46. a pre-defined sequence, if the paramter is present then it is 
  47. either a constant integer value (0 if not present) or an expression
  48. in which case the value is a pointer to the end of this line of pcode
  49. where the expression pcode will be found.
  50. e.g.
  51.  
  52. 3,1,3,2,999,999,1,3,2,999,999,1,1,1,3,2,999,999
  53.  
  54. Would read as:    
  55.     3 = box, expecting two expressions, color pointer, justify flag
  56.     1 = Start of expression
  57.     3 = Length of expression in long words
  58.     2 = floating point number follows
  59.     999,999 = double precision floating point number 
  60.     1 = Start of expression
  61.     3 = Length of expression in long words
  62.     2 = floating point number follows
  63.     999,999 = double precision floating point number 
  64.     1 = justify left
  65.     1 = There is a fill color,  and it starts  the next number along
  66.     1 = Start of expression (which is a color)
  67.     3 = Length of expression in long words
  68.     2 = floating point number follows
  69.     999,999 = double precision floating point number 
  70.  
  71. Complicated eh?, I'm sure I had a good reason for it!!!.
  72.  
  73. It's actually fairly easy to use, there are routines to deal 
  74. with all the messy bits.
  75. -----------------------------------------------------------------------------
  76. To define a new command you would do the following:
  77.     1) Add the keyword to KEYWORD.C (in alphabetical order)
  78.     2) EDT GLOBAL.H and define the syntax of any optional
  79.        parameters, (heres that done for BOX)
  80.  
  81. struct op_key op_box[] = {
  82.          "JUSTIFY",     typ_justify,     1, 0
  83.         ,"JUST",     typ_justify,     1, 0
  84.         ,"NOSTROKE",     typ_switch,     2, 1
  85.         ,"NOBORDER",     typ_switch,     2, 1
  86.         ,"FILL",     typ_fill,     3, 0
  87.         ,"NAME",     typ_str,     4, 0
  88.         ,"END",     typ_end,     0, 0  };
  89.  
  90.     3) Add a few lines in PASS.C to compile the command, e.g.
  91.  
  92. case 7 :    /* box x y  [left | center | right]  [fill xxx] name*/
  93.     get_xy();
  94.     get_optional(op_box);
  95.     break;
  96.  
  97.     4) Add a few lines to RUN.C to execute the command. e.g.
  98. case 1:  /* ALINE x y ARROW both | start | end */
  99.     readval(x);
  100.     readval(y);
  101.     marrow = *(pcode + (cp++));
  102.     if (marrow>0) g_get_xy(&ox,&oy);
  103.     if (marrow & 1)  g_arrow(x-ox,y-oy);
  104.     g_line(x,y);
  105.     if (marrow & 2)  g_arrow(ox-x,oy-y);
  106.     break;
  107.  
  108. -----------------------------------------------------------------------------
  109. Adding a command to the graph module is much easier, as it doesn't
  110. compile first.  For example when I added the GRID command to the 
  111. xaxis and yaxis I only had to add the lines:
  112. --
  113. static int xxgrid[5];
  114. --
  115.            else kw("GRID") xxgrid[t] = true;
  116. --
  117.     for (i=1;i<=4;i++) {
  118.         if (xxgrid[i]) {
  119.             if ((i & 1) == 1) {
  120.                 xx[i].ticks_length = ylength;
  121.             } else {
  122.                 xx[i].ticks_length = xlength;
  123.             }
  124.             xx[i].subticks_length = .0000001;
  125.         }
  126.     }
  127. --
  128. to GRAPH.C.  The array xx[] contains the structures which define the 
  129. four axis'es.
  130.     
  131. -----------------------------------------------------------------------------
  132. This version of CGLE gives a very BAD emulation of TEX, it is 
  133. really only TEX-Like in appearance, there are bugs and gaps in 
  134. the TEX-primitives which result in most of the power not being available. 
  135.  
  136. A PCODE mechanism is used by the TEX module to process text.
  137. First any macro's in the paragraph are executed, giving a larger
  138. paragraph with only text and TEX-primitives, then this is run 
  139. thru a routine which converts it into pcode. e.g.
  140.     1 = font,character
  141.     2 = move, x, y
  142.     3 = glue,stretch,shrink
  143.     etc.
  144. This is then wrapped and filled at the correct width, the glue is 'set'
  145. and then as a last step the text is drawn.
  146. -----------------------------------------------------------------------------
  147.  
  148. AXIS.C
  149.     The routines for drawing an axis (x,y,x2,y2) is passed a 
  150.     structure defined in AXIS.H which describes the axis.
  151.  
  152. BEGIN.C
  153.     Some utility routines for dealing with the begin...end structures.
  154.  
  155.     begin_token(long **pcode,int *cp,int *pln,char *srclin,char *tk,int *ntk,char *outbuff)
  156.     begin_init()
  157.     begin_next_line(long *pcode, int *cp)
  158.  
  159. B_TAB.C
  160.     The BEGIN TABLE routines.
  161.  
  162. B_TEXT.C
  163.     The BEGIN TEXT routines, (calls TEX.C for most of the guts)
  164.  
  165. CORE.C
  166.     Core graphics routines, g_*(),  this is the only file which 
  167.     makes calls to the driver routines d_*()
  168.  
  169. CURVE.C
  170.     A routine to convert CURVE X Y  X Y  X Y   etc into a sequence
  171.     of bezier curves.
  172.  
  173. DRAWIT.C
  174.     Main routine for drawing the current GLE file, this calls
  175.     PASS.C to compile the gle commands into PCODE and then 
  176.     calls DO_PCODE (RUN.C) to execute each line of cgle.
  177.  
  178. DVIBIT.C
  179.     Common part of the pc bitmap drivers.
  180.     
  181. DVIEP24.C
  182.     Epson 24pin driver.
  183.  
  184. DVIEPSON.C
  185.     Epson 8pin driver.
  186.  
  187. DVILJ.C
  188.     Laser Jet driver.
  189.  
  190. DVILJ300.C
  191.     300dpi laserjet driver.
  192.  
  193. DVISCR.C
  194.     Test bitmap driver which outputs to the screen
  195.  
  196. D_DVI.C
  197.     Generic DVI driver, create OUT.DVI files read by bitmap drivers.
  198.     the OUT.DVI file contains vector and fill commands.
  199.  
  200. D_HPGL.C     HPGL plotter driver.
  201. D_P79.C        P79 driver 
  202. D_PC.C        PC driver
  203. D_PS.C        PostScript driver
  204. D_REGIS.C    Regis (vt125, vt240) driver
  205. D_TEK.C        Tek4010 Driver
  206. D_UIS.C        vax vws/uis Driver
  207. D_VT100.C    VT100 driver
  208. D_X.C        DEC_Xwindow driver
  209. EASYDEV.C    Some routines to emulate clever things for dumb devices
  210. EDT.C        EDT like editor which the user is normally in.
  211. EVAL.C        Evaluates pcode expression.
  212. EXITCMD.C    
  213. FBUILD.C    For building font .FVE files from .GLE files.
  214. FITBEZ.C    Fits smooth curve to a dataset.
  215. FITCF.C        Actual routine for doing the smooth fit.
  216. FN.C        Used by PASS to find functions/subroutine names
  217. FONT.C        Routines for loading font files .fmt, .fve
  218. GENERAL.C    A couple of odd utility routines
  219. GLE.C        The MAIN() program which calls edt or drawit.
  220. GPRINT.C    Error messages are done thru GPRINT instead of PRINTF
  221. GRAPH.C        Main GRAPH compile routine
  222. GRAPH2.C    Graph draw routines
  223. KEY.C        Deals with BEGIN KEY ... 
  224. KEYWORD.C    Key words (binary search) and TEX key words.
  225. MAKEFMT.C    Makes font .FMT files from adobe  .AFM files.
  226. MEMORY.C    Handles memory allocating and freeing.
  227. MENU.C        Graph menu, and file selection menu.
  228. MOUSE.C        BIOS routines to use mouse.
  229. MYCHAR.C    For drawing characters using lines (instead of built in fonts)
  230. NAME.C        For finding/defining NAME'd objects
  231. PARSEAFM.C    Part of MAKEFMT
  232. POLISH.C    Passes expression, produces reverse polish pcode exp.
  233. PRINTBIT.C    Part of bitmap drivers.
  234. RUN.C        Executes one line of pcode. (draws it)
  235. SUB.C        Finds/defines subroutines
  236. TEX.C        LATEX text emulation stuff.
  237. TOKEN.C        Tokenizes one line, based on spaces, or special characters
  238. TURBO.C        Some vax equivalents to turboc routines
  239. TURBOSCR.C    TurboC windowing calls 
  240. VAR.C        Varialbe define/find
  241. VAXINKEY.C    Vax routine for retrieving one character.
  242. VAXSCR.C    Vax routines for emulating some turbo-c screen calls
  243.  
  244. ALL.H        Header file use by everything to load in standard .h files
  245. AXIS.H        Defines AXIS structures
  246. BEGIN.H        Define BEGIN... structures
  247. BITMAP.H    For BITMAP drivers
  248. COLOR.H        Defines some GLE format color macros.
  249. CORE.H        Prototypes for CORE routines, and data structures.
  250. EDT.H        EDT keypad definitions
  251. GLEPRO.H    Prototypes for most routines.
  252. GLOBAL.H    Structures and data for PASSing gle source
  253. GRAPH.H        Graph strutures and data 
  254. MYDEV.H        Device driver structures and data
  255.